package com.baicaoyuan.web.enums;


import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

@RequiredArgsConstructor
@Getter
public enum CrowdfundingStatusEnum {


    /**
     * 关闭
     */
    CLOSE("0"),

    /**
     * 初始化
     */
    INIT("1"),

    /**
     * 众筹中
     */
    ING("2"),

    /**
     * 众筹完成
     */
    FINISH("3"),

    /**
     * 筹备中
     */
    PREPARATION_ING("4"),

    /**
     * 筹备结束
     */
    PREPARATION_FINISHED("5"),

    /**
     * 营业中
     */
    ON_SALE("6"),

    /**
     * 分红
     */
    Dividend("18"),

    /**
     * 删除
     */
    DELETE("99");
    private final String status;

    /**
     * 根据标识获取枚举
     *
     * @param crowdfundingStatus
     * @return
     */
    public static CrowdfundingStatusEnum acquire(final String crowdfundingStatus) {
        Optional<CrowdfundingStatusEnum> statusEnum = Arrays.stream(CrowdfundingStatusEnum.values())
                .filter(s -> (Objects.equals(s.getStatus(), crowdfundingStatus)))
                .findFirst();
        return statusEnum.orElse(CrowdfundingStatusEnum.INIT);
    }
}

